package base.living;

import java.awt.Rectangle;

import base.Start;
import base.common.IBoundingBox;
import base.common.ILiving;
import base.world.World;

public abstract class Entity implements ILiving, IBoundingBox
{
	protected int posX;
	protected int posY;
	protected float posRot;

	protected Rectangle boundingBox;
	protected int shadowSize;

	protected boolean isDead;

	public Entity(int par1, int par2, float par3, Rectangle par4Rectangle)
	{
		this.posX = par1;
		this.posY = par2;
		this.posRot = par3;

		this.boundingBox = par4Rectangle;
		this.boundingBox.setLocation(this.posX - this.boundingBox.width / 2, this.posY - this.boundingBox.height / 2);
		this.shadowSize = (this.boundingBox.height + this.boundingBox.width) / 2;
	}

	public Entity(int par1, int par2, float par3, int par4)
	{
		this(par1, par2, par3, new Rectangle(par4, par4));
	}

	@Override
	public Rectangle getBoundingBox()
	{
		this.boundingBox.setLocation(this.posX - this.boundingBox.width / 2, this.posY - this.boundingBox.height / 2);
		return this.boundingBox;
	}

	@Override
	public void onInit() {}

	@Override
	public void onUpdate() {}

	@Override
	public void onDestroy() {}

	/**Get x position*/
	public int getPosX()
	{
		return this.posX;
	}

	/**Get y position*/
	public int getPosY()
	{
		return this.posY;
	}

	/**Get z rotation*/
	public float getPosRot()
	{
		return this.posRot;
	}

	/**Get shadow size; should be the mean of width and height*/
	public int getShadowSize()
	{
		return this.shadowSize;
	}

	/**Get current worldObj*/
	public World getWorldObj()
	{
		return Start.worldManager.theWorld;
	}

	@Override
	public boolean isDead()
	{
		return this.isDead;
	}

	public void setDead()
	{
		this.isDead = true;
	}
}
